home *** CD-ROM | disk | FTP | other *** search
-
- /******************************************************************************
-
- MODULE
- Examine.c
-
- DESCRIPTION
- Examine a certain file or Dir
-
- NOTES
- Kickstart 2.0+ required
- compiles w/ SAS/C v6.51
-
- BUGS
- none known
-
- TODO
-
- EXAMPLES
-
- SEE ALSO
-
- INDEX
-
- HISTORY
- 25-03-95 b_noll created
-
- AUTHOR
- Bernd Noll, Brunnenstrasse 55, D-67661 Kaiserslautern
- b_noll@informatik.uni-kl.de
-
- ******************************************************************************/
-
- /**************************************
- Includes
- **************************************/
-
- #ifndef EXEC_LIBRARIES_H
- # include <exec/libraries.h>
- #endif /* EXEC_LIBRARIES_H */
-
- #ifndef CLIB_EXEC_PROTOS_H
- # include <clib/exec_protos.h>
- #endif /* CLIB_EXEC_PROTOS_H */
-
- #ifndef DOS_DOS_H
- # include <dos/dos.h>
- #endif /* DOS_DOS_H */
-
- #ifndef CLIB_DOS_PROTOS_H
- # include <clib/dos_protos.h>
- #endif /* CLIB_DOS_PROTOS_H */
-
- #include <proto/dos.h>
- #include <proto/exec.h>
-
- /**************************************
- Defines & Structures
- **************************************/
-
- #ifndef ABSEXECBASE
- #define ABSEXECBASE ((struct ExecBase **)4L)
- #endif
-
- struct _arg {
- /* ******************** USER FORMAT ******************** */
- #define FORMAT "PATH/A"
-
- STRPTR path;
-
- /* ******************** USER FORMAT ******************** */
- }; /* struct _argv */
-
- #define MAXPATHLEN 256
- #define MAXLINELEN 256
-
- #define VERSIONPREFIX "\0$VER: "
- #define VERSIONOFFSET 0
- #define FORMATPREFIX "\0$ARG: "
- #define FORMATOFFSET 7
-
- /**************************************
- Implementation
- **************************************/
-
- long _main (void)
- {
- const char* version = VERSIONPREFIX "Examine 1.0 " __AMIGADATE__ + VERSIONOFFSET;
- long retval = RETURN_FAIL;
- struct ExecBase*SysBase = *ABSEXECBASE;
- struct Library* DOSBase;
-
- if (DOSBase = OpenLibrary (DOSNAME, 37)) {
- struct _arg argv = { 0 };
- APTR args;
- retval = RETURN_ERROR;
- if (args = (void*)ReadArgs(FORMATPREFIX FORMAT + FORMATOFFSET, (LONG*)&argv, NULL)) {
-
- /* ******************** USER BODY ******************** */
- {
- BPTR lock;
-
- if (lock = Lock(argv.path, SHARED_LOCK)) {
- struct FileInfoBlock *fib;
- if (fib = AllocDosObject(DOS_FIB, NULL)) {
- if (Examine (lock, fib)) {
- STRPTR det[] = {
- "ST_PIPEFILE", "ST_LINKFILE", "ST_FILE",
- "?", "?", "?",
- "ST_ROOT", "ST_USERDIR", "ST_SOFTLINK",
- "ST_LINKDIR"
- };
- UBYTE prot[] = "rwedrwed-sparwed";
-
- {
- LONG i,p;
- # define MAXMBIT 15
- # define MINMBIT 4
- # define MAXUBIT 3
- # define MINUBIT 0
- p = fib->fib_Protection;
- for (i = MAXMBIT; i >= MINMBIT; -- i)
- if (!(p & (1 << i)))
- prot[MAXMBIT - i] = '-';
- for (i = MAXUBIT; i >= MINUBIT; -- i)
- if ((p & (1 << i)))
- prot[MAXMBIT - i] = '-';
- }
-
-
- Printf("DiskKey = 0x%04lx;\n"
- "DirEntryType= %ld; /* %s */\n"
- "FileName = \"%s\";\n"
- "Protection = \"%s\";\n"
- "EntryType = %ld; /* %s */\n"
- "Size = %ld;\n"
- "NumBlocks = %ld;\n"
- "Comment = \"%s\";\n"
- "OwnerUID = 0x%04lx;\n"
- "OwnerGID = 0x%04lx;\n"
- ,
- fib->fib_DiskKey,
- fib->fib_DirEntryType, det[fib->fib_DirEntryType+5],
- fib->fib_FileName,
- /*fib->fib_Protection, */ prot,
- fib->fib_EntryType, det[fib->fib_EntryType+5],
- fib->fib_Size,
- fib->fib_NumBlocks,
- fib->fib_Comment,
- fib->fib_OwnerUID,
- fib->fib_OwnerGID,
- 0);
-
- } /* if */
- FreeDosObject(DOS_FIB, fib);
- } /* if */
- UnLock(lock);
- } /* if */
- }
- /* ******************** USER BODY ******************** */
- FreeArgs (args);
- } /* if */
-
- if (retval > RETURN_WARN)
- PrintFault(IoErr(), "Examine");
-
- CloseLibrary (DOSBase);
- } /* if */
- return (retval);
- } /* _main */
-
- /******************************************************************************
- ***** END Examine.c
- ******************************************************************************/
-
-
-